/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jollylengkono.skripsi.Comments.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jollylengkono.skripsi.dao.CommentsDao;
import jollylengkono.skripsi.model.Comments;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author hp02
 */
public class CommentsRead extends Action {
    private String FORWARD;
    
    public CommentsRead() {
    }

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        long id = Long.parseLong(request.getParameter("c_id"));
        Comments comment = (Comments) new CommentsDao().read(id);
        if (comment==null) {
            this.FORWARD="fail";
        } else {
            this.FORWARD="success";
            request.setAttribute("comment", comment);
        }
        return mapping.findForward(FORWARD);
    }
}
